import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;


public class IncomeStatementPanel extends JPanel {
	private JTable table;
	private String[]month ={"January",  "Febuary",  "March", 
			"April",  "May",  "June",  "July",  "August",  
			"September",  "October",  "November",  "December"};
	private String[]year ={"2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", 
			"2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", 
			"2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", 
			"2030", "2031","2032"};
	private JTextField textField;
	
	public IncomeStatementPanel() {
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		JLabel lblMonth = new JLabel("Month:");
		add(lblMonth);
		
		JComboBox comboBox = new JComboBox(month);
		springLayout.putConstraint(SpringLayout.WEST, comboBox, 74, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.NORTH, lblMonth, 4, SpringLayout.NORTH, comboBox);
		springLayout.putConstraint(SpringLayout.EAST, lblMonth, -6, SpringLayout.WEST, comboBox);
		springLayout.putConstraint(SpringLayout.NORTH, comboBox, 105, SpringLayout.NORTH, this);
		add(comboBox);
		
		JComboBox comboBox_1 = new JComboBox(year);
		springLayout.putConstraint(SpringLayout.NORTH, comboBox_1, 105, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, comboBox_1, -139, SpringLayout.EAST, this);
		springLayout.putConstraint(SpringLayout.EAST, comboBox_1, -69, SpringLayout.EAST, this);
		add(comboBox_1);
		
		JLabel lblYear = new JLabel("Year:");
		springLayout.putConstraint(SpringLayout.EAST, comboBox, -104, SpringLayout.WEST, lblYear);
		springLayout.putConstraint(SpringLayout.NORTH, lblYear, 0, SpringLayout.NORTH, lblMonth);
		springLayout.putConstraint(SpringLayout.EAST, lblYear, -6, SpringLayout.WEST, comboBox_1);
		add(lblYear);
		
		table = new JTable();
		springLayout.putConstraint(SpringLayout.NORTH, table, 56, SpringLayout.SOUTH, comboBox);
		springLayout.putConstraint(SpringLayout.WEST, table, 0, SpringLayout.WEST, lblMonth);
		springLayout.putConstraint(SpringLayout.SOUTH, table, 216, SpringLayout.SOUTH, comboBox);
		springLayout.putConstraint(SpringLayout.EAST, table, 0, SpringLayout.EAST, comboBox_1);
		table.setSurrendersFocusOnKeystroke(true);
		table.setFont(new Font("Times New Roman", Font.PLAIN, 12));
		table.setFillsViewportHeight(true);
		table.setColumnSelectionAllowed(true);
		table.setCellSelectionEnabled(true);
		table.setModel(new DefaultTableModel(
				new Object[][] {
					{null, null, null},
					{null, null, null},
					{null, null, null},
					{null, null, null},
					{null, null, null},
					{null, null, null},
					{null, null, null},
					{null, null, null},
					{null, null, null},
					{null, null, null},
				},
				new String[] {
					"Time", "Patient Name", "Reason"
				}
			) {
				Class[] columnTypes = new Class[] {
					String.class, Object.class, Object.class
				};
				public Class getColumnClass(int columnIndex) {
					return columnTypes[columnIndex];
				}
			});
			table.getColumnModel().getColumn(0).setPreferredWidth(80);
			table.getColumnModel().getColumn(1).setPreferredWidth(120);
			table.getColumnModel().getColumn(2).setPreferredWidth(150);
		add(table);
		
		JLabel lblNewLabel = new JLabel("Date Visited");
		springLayout.putConstraint(SpringLayout.WEST, lblNewLabel, 0, SpringLayout.WEST, lblMonth);
		springLayout.putConstraint(SpringLayout.SOUTH, lblNewLabel, -6, SpringLayout.NORTH, table);
		add(lblNewLabel);
		
		JLabel lblPatientName = new JLabel("Patient Name");
		springLayout.putConstraint(SpringLayout.NORTH, lblPatientName, 0, SpringLayout.NORTH, lblNewLabel);
		springLayout.putConstraint(SpringLayout.WEST, lblPatientName, 16, SpringLayout.EAST, lblNewLabel);
		add(lblPatientName);
		
		JLabel lblPrice = new JLabel("Price");
		springLayout.putConstraint(SpringLayout.WEST, lblPrice, 43, SpringLayout.EAST, lblPatientName);
		springLayout.putConstraint(SpringLayout.SOUTH, lblPrice, -6, SpringLayout.NORTH, table);
		add(lblPrice);
		
		JLabel lblTotal = new JLabel("Total:");
		springLayout.putConstraint(SpringLayout.EAST, lblTotal, 0, SpringLayout.EAST, lblPrice);
		add(lblTotal);
		
		textField = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, lblTotal, 3, SpringLayout.NORTH, textField);
		springLayout.putConstraint(SpringLayout.NORTH, textField, 30, SpringLayout.SOUTH, table);
		springLayout.putConstraint(SpringLayout.EAST, textField, 0, SpringLayout.EAST, comboBox_1);
		add(textField);
		textField.setColumns(10);
		
		JLabel lblMonthlyIncomeStatement = new JLabel("Monthly Income Statement ");
		springLayout.putConstraint(SpringLayout.NORTH, lblMonthlyIncomeStatement, 23, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblMonthlyIncomeStatement, 91, SpringLayout.WEST, this);
		lblMonthlyIncomeStatement.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
		add(lblMonthlyIncomeStatement);
		
		JButton btnPrintStatement = new JButton("Print Statement");
		springLayout.putConstraint(SpringLayout.NORTH, btnPrintStatement, 56, SpringLayout.SOUTH, textField);
		springLayout.putConstraint(SpringLayout.EAST, btnPrintStatement, 0, SpringLayout.EAST, comboBox_1);
		add(btnPrintStatement);
	}
}
